package com.hudson.example.hudsonmq;


import com.hudsonmq.spring.impl.consume.AbstractHudsonMQListener;
import com.hudsonmq.spring.impl.consume.HudsonMQConsumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @Author: 渔小鲤
 * @DateTime: 2025/7/12 17:52
 **/
@HudsonMQConsumer(topic = "test")
public class HudsonMQListenerTest extends AbstractHudsonMQListener {
    private static final Logger logger = LoggerFactory.getLogger(HudsonMQListenerTest.class);

    @Override
    public void onMessage(byte[] message) throws Exception {
        logger.debug("消费開始，消息为：{}", new String(message));
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        } finally {
            logger.debug("消费成功，消息为：{}", message);
        }

        throw new Exception();
    }
}
